In this example we are going to extend the functionality of Task Manager showcase (which comes
by default with Trilium) by adding a button in the Launch Bar (
) to create a new task automatically and open it.
#run=frontendStartup label in Attributes.Copy-paste the following script:
api.addButtonToToolbar({
title: "New task",
icon: "task",
shortcut: "alt+n",
action: async () => {
const taskNoteId = await api.runOnBackend(() => {
const todoRootNote = api.getNoteWithLabel("taskTodoRoot");
const resp = api.createTextNote(todoRootNote.noteId, "New task", "")
return resp.note.noteId;
});
await api.waitUntilSynced();
await api.activateNewNote(taskNoteId);
}
});
Since we set the script to be run on start-up, all we need to do is to refresh the application.
|
This uses the Front-end API to create a icon in the Launch Bar, by specifying:
|
|
|
|
|
|
|
|
|
|
|